/*
* Copyright (C) 2007, Alberto Giannetti
*
* This file is part of Hudson.
*
* Hudson is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hudson is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Hudson.  If not, see <http://www.gnu.org/licenses/>.
*/

// Boost
#include <boost/date_time/gregorian/gregorian.hpp>

// Hudson
#include "BnHTrader.hpp"

using namespace std;
using namespace boost::gregorian;


BnHTrader::BnHTrader(const DB& db):
  _db(db)
{
}


void BnHTrader::run(void)
{
  Position::ID id = buy(_db.name(), _db.begin()->first, Price(_db.begin()->second.open));
  close(id, _db.rbegin()->first, Price(_db.rbegin()->second.adjclose));
}
